<template>
  <div class="home">
    <header class="header">
      <nav class="nav">
        <div class="nav-brand">
          <h1>极简博客</h1>
        </div>
        <div class="nav-links">
          <a href="#" class="nav-link active">首页</a>
          <a href="#" class="nav-link">文章</a>
          <a href="#" class="nav-link">关于</a>
        </div>
      </nav>
    </header>

    <main class="main">
      <section class="hero">
        <div class="hero-content">
          <h2 class="hero-title">欢迎来到我的极简博客</h2>
          <p class="hero-subtitle">在这里分享我的思考和见解</p>
        </div>
      </section>

      <section class="blog-posts">
        <div class="container">
          <h3 class="section-title">最新文章</h3>
          <div class="posts-grid">
            <article class="post-card" v-for="post in posts" :key="post.id">
              <div class="post-image">
                <img :src="post.image" :alt="post.title" />
              </div>
              <div class="post-content">
                <h4 class="post-title">{{ post.title }}</h4>
                <p class="post-excerpt">{{ post.excerpt }}</p>
                <div class="post-meta">
                  <span class="post-date">{{ post.date }}</span>
                  <span class="post-category">{{ post.category }}</span>
                </div>
              </div>
            </article>
          </div>
        </div>
      </section>
    </main>

    <footer class="footer">
      <div class="container">
        <p>&copy; 2024 极简博客. 保留所有权利.</p>
      </div>
    </footer>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const posts = ref([
  {
    id: 1,
    title: 'Vue3 组合式 API 实践指南',
    excerpt: '探索 Vue3 组合式 API 的强大功能和使用技巧，提升开发效率。',
    date: '2024-01-15',
    category: '前端开发',
    image: 'https://picsum.photos/400/250?random=1'
  },
  {
    id: 2,
    title: '现代 CSS 布局技术解析',
    excerpt: '深入了解 Flexbox 和 Grid 布局，打造响应式网页设计。',
    date: '2024-01-12',
    category: 'CSS',
    image: 'https://picsum.photos/400/250?random=2'
  },
  {
    id: 3,
    title: 'JavaScript 性能优化技巧',
    excerpt: '分享一些实用的 JavaScript 性能优化方法和最佳实践。',
    date: '2024-01-10',
    category: 'JavaScript',
    image: 'https://picsum.photos/400/250?random=3'
  }
])
</script>

<style scoped>
.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand h1 {
  color: #2c3e50;
  font-size: 1.5rem;
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-link {
  color: #666;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
}

.nav-link:hover,
.nav-link.active {
  color: #3498db;
}

.main {
  flex: 1;
}

.hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 4rem 2rem;
  text-align: center;
}

.hero-title {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.hero-subtitle {
  font-size: 1.2rem;
  opacity: 0.9;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.blog-posts {
  padding: 4rem 0;
}

.section-title {
  font-size: 2rem;
  text-align: center;
  margin-bottom: 3rem;
  color: #2c3e50;
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
}

.post-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  transition: transform 0.3s, box-shadow 0.3s;
}

.post-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.post-image {
  height: 200px;
  overflow: hidden;
}

.post-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.post-card:hover .post-image img {
  transform: scale(1.05);
}

.post-content {
  padding: 1.5rem;
}

.post-title {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: #2c3e50;
  line-height: 1.4;
}

.post-excerpt {
  color: #666;
  margin-bottom: 1rem;
  line-height: 1.6;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: #999;
}

.post-category {
  background: #e3f2fd;
  color: #1976d2;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 500;
}

.footer {
  background: #2c3e50;
  color: white;
  text-align: center;
  padding: 2rem;
}

@media (max-width: 768px) {
  .nav {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .posts-grid {
    grid-template-columns: 1fr;
  }
  
  .container {
    padding: 0 1rem;
  }
}
</style>